FROM ubuntu
LABEL description="aliyun source,jdk 1.8,maven 3.6,docker"

RUN mkdir -p /var/run/jenkins

COPY aliyun.source /etc/apt/sources.list
COPY docker_push.sh /usr/bin/docker_push.sh

ENV JAVA_HOME /opt/jdk1.8.0_231
ENV M2_HOME /opt/apache-maven-3.6.2
ENV PATH $M2_HOME/bin:$JAVA_HOME/bin:$PATH
ENV JENKINS_HOME /var/lib/jenkins
ENV DEBIAN_FRONTEND noninteractive

RUN  apt-get clean all \
    && apt-get update && apt-get upgrade -y \
    && apt-get install -y wget daemon psmisc net-tools apt-transport-https ca-certificates software-properties-common \
    && wget -q -O - https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
    && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
    && apt-get update \
    && wget http://dev8.cn:8001/env/jdk-8u231-linux-x64.tar.gz -P /opt \
    && wget http://dev8.cn:8001/env/jenkins_2.190.1_all.deb -P /opt \
    && wget http://dev8.cn:8001/env/apache-maven-3.6.2-bin.tar.gz -P /opt \
    && tar -zxf  /opt/jdk-8u231-linux-x64.tar.gz -C /opt/ \
    &&  chmod -R +x /opt/jdk1.8.0_231 \
    && ln -s $JAVA_HOME/bin/java /usr/bin/java \
    && apt-get install -y docker-ce \
    && tar -zxf /opt/apache-maven-3.6.2-bin.tar.gz -C /opt/ \
    && dpkg -i /opt/jenkins_2.190.1_all.deb \
    && usermod -aG jenkins root \
    && usermod -aG docker jenkins \
    && chmod +x /usr/bin/docker_push.sh \
    && rm -rf /opt/jdk-8u231-linux-x64.tar.gz \
    && rm -rf /opt/jenkins_2.190.1_all.deb \
    && rm -rf /opt/apache-maven-3.6.2-bin.tar.gz \
    && apt --purge remove -y wget daemon psmisc net-tools apt-transport-https ca-certificates software-properties-common


    #&& wget -q -O - https://get.docker.com | bash -s docker --mirror Aliyun \

COPY jenkins.conf /etc/default/jenkins
ENTRYPOINT service docker start && service jenkins start && /bin/bash


# for main web interface:
EXPOSE 8080
